package xml;

import java.util.Collection;

import logic.AdminHandler;
import logic.CorrelationRecAlgorithm;
import logic.Facade;
import logic.SystemHandler;
import logic.UserHandler;
import data.MovieTuple;
import data.RatingTuple;
import data.SystemData;
import data.UserTuple;
import exceptions.ObjectAlreadyInitializedException;

public class SqlToXml{
	public static void main(String[] args){
		try { 
			Facade.init(new SystemHandler(), new AdminHandler() , new UserHandler(),new CorrelationRecAlgorithm());
			SystemData.doSQL();
			Collection<UserTuple> users = SystemData.getInstance().getAllUsers();
			Collection<MovieTuple> movies = SystemData.getInstance().getAllMovies();
			Collection<RatingTuple> ratings = SystemData.getInstance().getAllRatings();
			DataManipulate.writeToFileWithName(users, movies, ratings, "sql_backup.xml");
		} catch (ObjectAlreadyInitializedException e) {
			e.printStackTrace();
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
}
